/**
 * 
 */
package square;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Test;

/**
 * A class collection tests for the Temperature class.
 * @author Inge
 *
 */
public class TemperatureTest {



	/**
	 * Set up an immutable test fixture.
	 * 
	 * @post	The variable temperature300Celcius references a new
	 * 			temperature with a numeric value of 300 and 
	 * 			Celcius as its temperaturescale.
	 * @post	The variable temperature57315Kelvin references a new
	 * 			temperature with a numeric value of 573,15 and 
	 * 			Kelvin as its temperaturescale.
	 * @post	The variable temperature572Fahrenheit references a new
	 * 			temperature with a numeric value of 572 and 
	 * 			Fahrenheit as its temperaturescale.
	 */
	@Before
	public void setUpImmutableFixture() throws Exception {
		temperature300Celcius = new Temperature(300);
		temperature57315Kelvin = new Temperature(573.15, TemperatureScale.KELVIN);
		temperature572Fahrenheit = new Temperature(572, TemperatureScale.FAHRENHEIT);
	}

	@Test
	public void conservationOfValueAfterConversion(){
		assertTrue(temperature300Celcius.convertTo(TemperatureScale.KELVIN).equals(temperature57315Kelvin));
		assertTrue(temperature300Celcius.convertTo(TemperatureScale.FAHRENHEIT).equals(temperature572Fahrenheit));
		assertTrue(temperature572Fahrenheit.convertTo(TemperatureScale.CELCIUS).equals(temperature300Celcius));
		assertTrue(temperature572Fahrenheit.convertTo(TemperatureScale.KELVIN).equals(temperature57315Kelvin));
		assertTrue(temperature57315Kelvin.convertTo(TemperatureScale.CELCIUS).equals(temperature300Celcius));
		assertTrue(temperature57315Kelvin.convertTo(TemperatureScale.FAHRENHEIT).equals(temperature572Fahrenheit));
	}
	
	public void compareTo(){
		assertEquals(temperature300Celcius.compareTo(temperature300Celcius), 0);
		assertEquals(temperature300Celcius.compareTo(temperature57315Kelvin), 0);
		assertEquals(temperature572Fahrenheit.compareTo(temperature300Celcius),0);
		assertEquals(temperature572Fahrenheit.compareTo(temperature57315Kelvin),0);
		assertEquals(temperature57315Kelvin.compareTo(temperature300Celcius), 0);
		assertEquals(temperature57315Kelvin.compareTo(temperature57315Kelvin),0);
	}
	
	@Test
	public void validTemperatureScales(){
		assertTrue(Temperature.isValidTemperatureScale(TemperatureScale.CELCIUS));
		assertTrue(Temperature.isValidTemperatureScale(TemperatureScale.KELVIN));
		assertTrue(Temperature.isValidTemperatureScale(TemperatureScale.FAHRENHEIT));
		assertFalse(Temperature.isValidTemperatureScale(null));
	}
	
	@Test
	public void validTemperatureValue(){
		assertTrue(Temperature.isValidTemperatureValue(temperature300Celcius.getTemperatureValue(),temperature300Celcius.getTemperatureScale()));
		assertFalse(Temperature.isValidTemperatureValue(-3, TemperatureScale.KELVIN));
	}

	
	private static Temperature temperature300Celcius;
	private static Temperature temperature57315Kelvin;
	private static Temperature temperature572Fahrenheit;
}
